﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Kronos.DatabaseModels;
using Kronos.Classes;
using Kronos.Pages;
using Kronos.Webservices;

namespace Kronos.Classes
{
    public class CourseInformation
    {
        //whatever is public here are the columns
        public string Name { get; set; }
        public string Code { get; set; }
        public string Preqs { get; set; }
        public string Note { get; set; }
        public double Credits { get; set; }

       private DataGrid classGrid=new DataGrid();
       private soen341dBEntities dataBase=new soen341dBEntities();
       private List<CourseInformation> classOnTable = new List<CourseInformation>();

       public CourseInformation()
       {
           //default constructor
       }
       public CourseInformation(DataGrid classGrid)
       {
           //overloaded constructor
           this.classGrid = classGrid;
           //query
           var classes = from c in dataBase.Courses
                         select c;
           //do it for each result in the query
           foreach (var c in classes)
           {
               
               classOnTable.Add(new CourseInformation() {Credits=c.credits, Name = c.courseName, Code = (c.courseCode + " " + c.courseNumber), Preqs = c.prereq, Note = c.specialNote });
           }
           //set the components source data
           classGrid.DataSource = classOnTable;
           //saves the data in the structure
           classGrid.DataBind();

       }

    }




}